﻿#region Disclaimer/Info
///////////////////////////////////////////////////////////////////////////////////////////////////
// MetaCollection
// 
// MetaCollection is a system to provide a standard structure, permissions and metadata service
// for content organization.
//
// This project is hosted at Google Code at http://code.google.com/p/metacollection/
//
// This project is licensed under the BSD license.  See the License.txt file for more information.
///////////////////////////////////////////////////////////////////////////////////////////////////
#endregion

using System;
using System.Configuration;

namespace MetaCollection.Framework.Configuration
{
	/// <summary>
	/// Configuration Element for a Resource Provider.
	/// </summary>
	public class ProviderReferenceElement : ConfigurationElementBase<Guid>
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="ProviderReferenceElement"/> class.
		/// </summary>
		public ProviderReferenceElement() : this(Guid.Empty, String.Empty, String.Empty, String.Empty) { }

		/// <summary>
		/// Initializes a new instance of the <see cref="ProviderReferenceElement"/> class.
		/// </summary>
		/// <param name="name">The name.</param>
		/// <param name="id">The id.</param>
		/// <param name="providerId">The provider id.</param>
		public ProviderReferenceElement(Guid id, String name, String typeName, string assemblyName)
		{
			Id = id; 
			Name = name;
			AssemblyName = assemblyName;
			TypeName = typeName;
		}

		/// <summary>
		/// Gets or sets the TypeName.
		/// </summary>
		/// <value>The TypeName.</value>
		[ConfigurationProperty("typeName", IsRequired = true, IsKey = false)]
		public string TypeName
		{
			get
			{
				return (string)this["typeName"];
			}
			set
			{
				this["typeName"] = value;
			}
		}

		/// <summary>
		/// Gets or sets the AssemblyName.
		/// </summary>
		/// <value>The AssemblyName.</value>
		[ConfigurationProperty("assemblyName", IsRequired = true, IsKey = false)]
		public string AssemblyName
		{
			get
			{
				return (string)this["assemblyName"];
			}
			set
			{
				this["assemblyName"] = value;
			}
		}

		/// <summary>
		/// Gets or sets the name.
		/// </summary>
		/// <value>The name.</value>
		[ConfigurationProperty("name", IsRequired = true, IsKey = false)]
		public string Name
		{
			get
			{
				return (string)this["name"];
			}
			set
			{
				this["name"] = value;
			}
		}

		/// <summary>
		/// Gets or sets the Id.
		/// </summary>
		/// <value>The Id.</value>
		[ConfigurationProperty("id", IsRequired = true, IsKey = true)]
		public Guid Id
		{
			get
			{
				return (Guid)this["id"];
			}
			set
			{
				this["id"] = value;
			}
		}

		/// <summary>
		/// Gets the key.
		/// </summary>
		/// <value>The key.</value>
		protected internal override Guid Key
		{
			get { return this.Id; }
		}
	}
}
